package myLandscape.Main;

import android.app.Activity;
import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;

public class AnglesManager implements SensorEventListener {
	private final SensorManager mSensorManager;
    private final Sensor mRotationVector;
    private final Activity main;
    private boolean upArrowState;
    private boolean downArrowState;
    private boolean leftArrowState;
    private boolean rightArrowState;
	private boolean isInTheRightPosition;
    
    public AnglesManager(Activity Main) {
    		this.main = Main;
    	 mSensorManager = (SensorManager)main.getSystemService(Context.SENSOR_SERVICE);
 	 	mRotationVector = mSensorManager.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR);
    }
    
    protected void onResume() {
        mSensorManager.registerListener(this, mRotationVector, SensorManager.SENSOR_DELAY_NORMAL);
    }

    protected void onPause() {
        mSensorManager.unregisterListener(this);
    }

    public void onAccuracyChanged(Sensor sensor, int accuracy) {
    }

    public void onSensorChanged(SensorEvent event) {
    	//event.values[0];
    	//event.values[1];
    	//event.values[2];
    }
    
    public boolean shouldDrawUpArrow() {
    	return upArrowState;
    }
    
    public boolean shouldDrawDownArrow() {
    	return downArrowState;
    }
 
 	public boolean shouldDrawRightArrow() {
 		return rightArrowState;
 	}
 
 	public boolean shouldDrawLeftArrow() {
 		return leftArrowState;
 	}
 	
 	public boolean isInTheRightPosition() {
 		return isInTheRightPosition;
 	}
}

